package com.mming.sso.util;

public class SaltUtil {
    public static String getSalt() {
        StringBuilder salt = new StringBuilder();
        // 用字符数组的方式随机
        String model = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        char[] m = model.toCharArray();
        for (int j = 0; j < 6; j++) {
            int random36 = (int) (Math.random() * 36);
            char c = m[random36];
            // 保证六位随机数之间没有重复的
            if (random36 > 9 && ((int) (Math.random() * 100)) % 2 == 0) {
                c = Character.toLowerCase(c);
            }
            if (salt.toString().contains(String.valueOf(c))) {
                j--;
                continue;
            }
            salt.append(c);
        }
        return salt.toString();
    }

}
